package TestDemo.example.mapper;

import TestDemo.example.pojo.Emp;
import TestDemo.example.pojo.EmpQueryParam;
import TestDemo.example.pojo.LoginInfo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
    //自己实现分页查询
//    @Select("select count(*) from emp e left join dept d on e.dept_id=d.id")
//    public Long empTotal();
//
//    public ArrayList<Emp>  findEmpRows(Integer start, Integer pageSize);
    //借助MyBatis中的 PageHelp插件 实现分页查询
    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id ORDER BY update_time DESC")
    public ArrayList<Emp> findEmplist();

    public ArrayList<Emp> findEmp(EmpQueryParam empQueryParam);

    //@Options(useGeneratedKeys = true,keyColumn = "id") //获取到生成的主键
    public void addEmp(Emp emp);

    public void deleteDeptById(ArrayList<Integer> idArrayList);

    Emp getById(Integer id);


    void updateEmp(Emp emp);

    @MapKey("pos")
    List<Map<String,Integer>> getEmpJobData();

    @MapKey("name")
    List<Map<String,Object>> getEmpGenderData();

    LoginInfo getLoginInfo(Emp emp);
}
